#include <iostream>
using namespace std;
const int N = 1010;
int g[N][N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cin >> g[i][j];
    int r = 0, c = 0;
    int q;
    cin >> q;
    while(q--)
    {
        int x;
        cin >> x;
        r = r ^ 1;
        if(x & 1)
            c = c ^ 1;
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cout << g[r ? n - i + 1 : i][c ? n - j + 1 : j] << " \n"[j == n];
        }
    }
    return 0;
}